package com.ruoyi.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

@Configuration
@EnableAsync
public class AsyncConfig {

    @Bean(name = "taskExecutor")
    public Executor taskExecutor() {
        // 定义线程池参数
        int corePoolSize = 2;
        int maxPoolSize = 5;
        long keepAliveTime = 200L;
        return Executors.newFixedThreadPool(corePoolSize, Executors.defaultThreadFactory());
    }
}